<?php
/**
 * Created by PhpStorm.
 * User: fangwenda
 * Date: 2016/10/6
 * Time: 下午10:07
 */
require 'vendor/autoload.php';
date_default_timezone_set('PRC');  //设置成中国时区
                              // Set email format to HTML

function sendMail($mail_address,$stu_name,$labname,$body)
{


    $mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->CharSet = "UTF-8";
    $mail->setLanguage('zh_cn', 'vendor/phpmailer/phpmailer/language');

    $mail->Host = 'smtp.163.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '';                 // SMTP username
    $mail->Password = '';                           // SMTP password
//$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 25;                                    // TCP port to connect to

    $mail->setFrom('', 'Java课程助教-方文达');
    $mail->addAddress($mail_address, $stu_name);     // Add a recipient
//$mail->addAddress('ellen@example.com');               // Name is optional


//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->isHTML(true);
    $mail->Subject =  'Java 作业评价--'.$labname;
    $mail->Body    = $body;
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    if(!$mail->send()) {
        echo '404';
//    echo '邮件错误: ' . $mail->ErrorInfo;
    } else {
        echo '200';
    }
}